package gui;

import java.awt.Button;
import java.awt.GridLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class ErrorMessage  extends JPanel{
	
	private String message;
	private JFrame frame;
	
	public ErrorMessage(String message){
		this.message = message;
		frame = new JFrame("Error");
		frame.setSize(300, 150);
		
		JLabel error = new JLabel("  " + message, JLabel.CENTER);
		
		Button ok = new Button(("OK"));
		
		ok.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseReleased(MouseEvent e) {
				frame.dispose();
			}
		});
		this.setLayout(new GridLayout(2,1));
		this.add(error);
		this.add(ok);
		frame.add(this);
		frame.setVisible(true);
	}
}
